package org.groupg.practice;

import org.mapdb.*;

import java.io.File;
import java.util.Map;
import java.util.concurrent.ConcurrentMap;

public class BasicKeyValueExample {
    public static void main(String[] args) {
        // 创建内存数据库
        DB db = DBMaker.memoryDB().make();

        // 创建并打开一个名为 "myMap" 的 HashMap
        HTreeMap<String, String> map = (HTreeMap<String, String>) db.hashMap("myMap").createOrOpen();

        // 添加数据
        map.put("name", "John Doe");
        map.put("email", "john@example.com");
        map.put("city", "New York");

        // 读取数据
        System.out.println("Name: " + map.get("name"));
        System.out.println("Email: " + map.get("email"));
        System.out.println("City: " + map.get("city"));

        // 关闭数据库
        db.close();
    }
}
